<script>
import LoginForm from '@/components/LoginForm.vue';
import RegisterForm from '@/components/RegisterForm.vue';

export default {
  components: {
    LoginForm,
    RegisterForm
  },
  computed: {
    isLogin() {
      return this.$route.query.type === 'register' ? false : true
    }
  },
  data() {
    return {
    };
  },
  methods: {
    toggleLogin() {
      this.$router.replace({
        query: {
          ...this.$route.query,
          type: this.isLogin ? 'register' : undefined
        }
      })
    }
  }
}
</script>

<template>
  <div class="login-view">
    <div class="login-title">
      欢迎登录～
    </div>
    <div class="login-container">
      <LoginForm ref="loginRef" v-show="isLogin" @register="toggleLogin()" />
      <RegisterForm v-show="!isLogin" @login="toggleLogin()"
        @success="toggleLogin(), $refs.loginRef.setUsername($event)" />

      <div class="login-footer">
        技术支持 xxxxxx技术有限公司 13500001234
      </div>
    </div>
  </div>
</template>

<style lang="less" scoped>
.login-view {
  height: 100%;
  background-size: 375px;
  background-image: url('../assets/images/bj-1.png');
  background-repeat: no-repeat;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;

  .login-title {
    line-height: 188px;
    height: 188px;
    font-size: 24px;
    color: white;
    padding-left: 20px;
    flex-shrink: 0;
  }

  .login-container {
    background-image: url('../assets/images/bj-2.png');
    background-repeat: no-repeat;
    background-position: bottom;
    background-size: 375px;
    border-top-left-radius: 50px;
    background-color: white;
    padding: 30px;
    padding-bottom: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .login-footer {
      height: 60px;
      line-height: 60px;
      text-align: center;
      font-size: 12px;
      color: #333;
    }
  }
}
</style>
